package com.k2data.k2app.mapper;

import com.k2data.k2app.domain.DeviceCond;
import com.k2data.k2app.domain.po.TMonitorVariable;
import com.k2data.k2app.mybatis.mapper.K2Mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lidong9144@163.com 17-4-5.
 */
@Mapper
@Repository
public interface TMonitorVariableMapper extends K2Mapper<TMonitorVariable> {

    List<TMonitorVariable> selectVariables(DeviceCond cond);

    List<TMonitorVariable> selectTypeNumByMPId(Long monitorPointId);
    List<TMonitorVariable> selectByMPId(Long monitorPointId);
    // 查询已经同步的变量
    List<TMonitorVariable> selectVariablesKmx(@Param("fieldGroup") String fieldGroup);

    @Update("UPDATE template_monitor_variable SET state=#{state} WHERE monitor_point_id=#{pointId} AND kmx_variable_name_en=#{nameEn}")
    int updateState(@Param("pointId") Long pointId, @Param("nameEn") String nameEn, @Param("state") Integer state);


    /**
     * 同步设备的关键指标
     * @param tVariableId 模板变量id
     * @return
     */
    void updateDeviceType(@Param("tVariableId") Long tVariableId);

}
